<template>
	<!-- 申请退款 -->
	<view class="form-container">
		<nt-order-detail :orderInfo="commonForm.orderInfo"></nt-order-detail>
		<nt-card label="设置费用">
			<view class="form-item vertical">
				<view class="form-item__label">现金金额：</view>
				<view class="form-item__content">
					<u-radio-group v-model="money">
						<u-radio shape="square" :name="it.value" :label="it.name" v-for="it in commonForm.formConfig.branchMoneyList" :key="it.value"></u-radio>
					</u-radio-group>
				</view>
			</view>
			<view class="form-item form-other" v-if="money === '其他'">
				<view class="form-item__content">
					<u--input v-model="money_other" placeholder="请输入金额"></u--input>
				</view>
			</view>
			<view class="form-item vertical">
				<view class="form-item__label">打赏金额：</view>
				<view class="form-item__content">
					<u-radio-group v-model="is_reward_price">
						<u-radio shape="square" :name="it.value" :label="it.name" v-for="it in rewardTypeList" :key="it.value"></u-radio>
					</u-radio-group>
				</view>
			</view>
			<view class="form-item form-other" v-if="is_reward_price == 1">
				<view class="form-item__content">
					<u--input v-model="reward_price" placeholder="请输入打赏金额"></u--input>
				</view>
			</view>
		</nt-card>
		<nt-button text="保存" @tap="submit"></nt-button>
	</view>
</template>

<script>
import { workerSettingCost } from "@/api"
export default {
	data(){
		return {
			money: "",
			money_other: "",
			is_reward_price: "0",
			reward_price: "",
			rewardTypeList: [{'name':'无','value':'0'},{'name':'有','value':'1'},],
			loading: false
		}
	},
	inject: ["commonForm"],
	created(){
	},
	methods: {
		// 提交转单申请
		submit(){
			if(!this.money) return this.toast("请选择现金金额")
			if(this.money === "其他" && !this.money_other) return this.toast("请输入金额")
			if(this.is_reward_price == "1" && !this.reward_price) return this.toast("请输入打赏金额")
			if(this.loading) return
			this.loading = true
			workerSettingCost({
				realorder_id: this.commonForm.options.id,
				money: this.money,
				money_other: this.money_other,
				reward_price: this.reward_price,
			}).then(res => {
				if(res.code === 1){
					this.toast("设置成功")
					setTimeout(() => this.back(), 1000)
				}
			}).finally(() => {
				this.loading = false
			})
		}
	}
}
</script>

<style scoped lang="scss">
@import "./style.scss";
/deep/ .u-radio{
	margin-right: 40rpx;
}
.form-item{
	margin-bottom: 40rpx;
}
</style>